<%@ page import="leihua.Person" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: LH
  Date: 2022/9/21
  Time: 12:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    //判断当前用户是否登录了，没登录返回login页面
    Person nowPerson = (Person) request.getSession().getAttribute("person");
    if (nowPerson==null){
        response.sendRedirect("/lab04/02/login.jsp");
    }
    //获取当前服务器中的用户
    ArrayList<Person> persons= (ArrayList<Person>) application.getAttribute("persons");
%>
<table>
    <thead>
    <tr>
        <th>姓名</th>
        <th>ip地址</th>
        <th>访问时间</th>
    </tr>
    </thead>
    <%
        if (persons!=null){
        for (Person person : persons){%>
    <tr>
        <td><%=person.getName()%> </td>
        <td><%=person.getIp()%></td>
        <td><%=person.getAccessTime()%></td>
    </tr>
      <% }
      }%>
</table>


<table>
    <tr>当前用户信息：</tr>
    <tr>
        <%
            if (nowPerson!=null){%>
        <td>姓名：<%=nowPerson.getName() %></td>
        <td>ip:<%=nowPerson.getIp() %></td>
        <td>访问时间：<%=nowPerson.getAccessTime() %></td>
    </tr>
    <tr><a href="/lab04/02/logout.jsp">退出登录</a></tr>
        <%  }
        %>

</table>
</body>
</html>
